<?php

namespace app\home\controller;

use app\common\model\User;
use think\Controller;
use think\Request;

class Login extends Controller
{
    //处理邮箱用户登录
    public function login(Request $request)
    {
        $input = $request->only(['email','pwd']);
        $re = (new User())->getLogin($input);
        return reJson($re);
    }
    //处理微信登录
    public function weLogin()
    {
        $code = input('get.code');
        $appid = config('wechat.appid');
        $secret = config('wechat.appsecret');
        $url = sprintf(config('wechat.url'),$appid,$secret,$code);
        // 发送请求
        return httpReq($url);
    }

    //获取微信用户信息
    public function weuser(Request $request)
    {
        $input = $request->only(['openid','user','pic']);
        //给模型
        return reJson((new User())->openid($input));
    }
}
